home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / libsrc / m / src / tanh.c < prev   
Encoding:
C/C++ Source or Header  |  1994-07-18  |  254 b   |  17 lines

  1. #include <math.h>
  2.  
  3. double tanh(double x)
  4. {
  5.   if (x > 50)
  6.     return 1;
  7.   else if (x < -50)
  8.     return -1;
  9.   else
  10.   {
  11.     const double ebig = exp(x);
  12.     const double esmall = 1.0/ebig;
  13.     return (ebig - esmall) / (ebig + esmall);
  14.   }
  15. }
  16.  
  17.